// 向服务器端发送请求索要推荐数据
$.ajax({
  tpye: 'get',
  url: '/posts/recommend',
  success: function (response) {
    // 为了让模板变成公共的，所以将模板写在了js文件中
    const recommendTpl = `
    {{each data}}
    <li>
      <a href="detail.html?id={{$value._id}}">
        <img src="{{$value.thumbnail}}" alt="">
        <span>{{$value.title}}</span>
      </a>
    </li>
    {{/each}}
    `;
    const html = template.render(recommendTpl, {data: response});
    $('#recommendBox').html(html);
  }
})